package com.example.demo.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @author maxf
 * @version 1.0
 * @ClassName ConnUtils
 * @Description
 * @date 2019/2/14 15:21
 */
public class MysqlUtils {
    private static String url = "jdbc:mysql://103.45.101.109:13306/test";

    static {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    public static Connection createCoon() {
        System.out.println("创建新连接，请求线程:" + Thread.currentThread().getName());
        try {
            return DriverManager.getConnection(url, "test", "test");
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

}
